package com.bangcommunity.bbframe.common.utils.io;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.StringReader;
import java.util.Properties;

/**
 * properties工具
 *
 * @author tanghc
 * @since v0.0.1
 */
public class PropertiesUtil {
    private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);

    public static Properties loadFromString(String config) {
        Properties tmp = new Properties();
        if (config == null || config.trim().length() == 0) {
            logger.debug("loadFromString fail no config");
            return tmp;
        }
        try {
            tmp.load(new StringReader(config));
        } catch (Exception e) {
            logger.warn("loadFromString exeption: config={},error={}", config, e.getMessage());
        }
        return tmp;

    }
}
